function main() {

    const self = this;

    let formPartEle = this.$$element("form_part_digxog");
    let documentNo = formPartEle.$$getRenderElement().getDocumentNo();

    let isEdit = documentNo != null && documentNo !== "";

    let pageRenderElement = this.$$root().$parent.$parent.$parent;
    debugger

    const regionId = self.$$("tree_single_select_551mpk").cValue;
    const stallOrganizationCode = self.$$("text_input_37yviy").cValue || "";
    let regionCode  = "";
    api.EXEC_FORMULA("ENTITY_SELECT_ONE('ds_tbl:t_5f91d2964abb4bd2a4e010f24b66a591',code,QUERY_EQ('id'," + regionId + "))").then(res => {
        regionCode = res.result;
        const params = [{
            name: "stall_organization_code",
            valueContent: stallOrganizationCode
        }, {
            name: "regionCode",
            valueContent: regionCode
        }];

        api.DATA_SOURCE_EXECUTE("ds_api:99936bfb-fa07-49ba-83b0-e4de71960348", "api", params, [], "").then((res) => {
            if (!res.hasError) {
                self.$$m("text_input_37yviy").props.defaultValue.value = JSON.parse(res.result).result;
                if (formPartEle) {
                    formPartEle.$$getRenderElement().onSave()
                        .then((res) => {
                            if (res) {
                                debugger
                                if (!isEdit){
                                    const verifyData = {
                                        applyTypeId: 1,
                                        objectId: res.result.documentNo,
                                        applyHumanId: res.result.root_f83u12.number_input_fr8if7,
                                        applyReason: '移动端场所申请'
                                    };
                                    addAuditRecord(verifyData);
                                }
                                console.log("保存成功");
                                pageRenderElement.goHistory(-1);
                            } else {
                                console.log("保存失败");
                            }
                        })
                }
            }
        });
    });


}

/**
 * law_stall_organization_holder_verify
 * 申请类型,1：疏导点，2：摊位，3:摊主
 * object_id
 * @returns {Promise<unknown>}
 */
function addAuditRecord(verifyData) {

    const insertVerifyRecordSql = [
        ['apply_type_id', `'${verifyData.applyTypeId}'`],
        ['object_id', `'${verifyData.objectId}'`],
        ['apply_human_id', `${verifyData.applyHumanId}`],
        ['apply_human_name', 'USER_NAME()'],
        ['apply_reason', `'${verifyData.applyReason}'`],
        ['verify_state_id', '0']
    ];

    const formattedFields = insertVerifyRecordSql.map(([key, value]) => {
        return `'${key}',${value}`;
    });

    const law_stall_organization_holder_verify = "ds_tbl:t_1aef92529dae4723ba36422faba4e546";
    const insertSql = `INSERT('${law_stall_organization_holder_verify}', [${formattedFields.join(',')}])`;
    console.log(insertSql);

    return new Promise((resolve, reject) => {
        api.EXEC_FORMULA(insertSql).then(res => {
            console.log(res);
            resolve(res);
        })
    })
}





